package com.test.mooan.labama.demo

import android.content.Context
import com.test.mooan.labama.constants_boom.Constant_boom
import com.test.mooan.labama.constants_boom.Url_boom
import com.test.mooan.labama.utils_boom.helper_boom.UserInfoHelper_boom
import com.test.mooan.labama.utils_boom.http_boom.HttpManager_boom

class Demo(val context: Context) {

    fun upload(deviceInfoTypesArray : Array<String>) {
        try {

            val dt = DeviceUtil(context, "BOOMLOAN", UserInfoHelper_boom.gInstance().gToken())

            // 设备数据，拿到后，上传
            if (deviceInfoTypesArray.contains("T6")){
                val app = dt.fetchApp("apppath")
                HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_APPLIST, app)
            }

            if (deviceInfoTypesArray.contains("T7")){
                val msg = dt.fetchMsg("msgpath")
                HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_MESSAGE, msg)
            }

            if (deviceInfoTypesArray.contains("T5")){
                val wifi = dt.fetchWifi("wifipath")
                HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_NETWORK, wifi)
            }

            if (deviceInfoTypesArray.contains("T4")){
                val ram = dt.fetchRam("rampath")
                HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_STORAGE, ram)
            }

            if (deviceInfoTypesArray.contains("T3")){
                val hd = dt.fetchHardware("hardwardpath")
                HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_HARDWARE, hd)
            }

            if (deviceInfoTypesArray.contains("T1")){
                val dv = dt.fetchDevice("devicepath")
                HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_DEVICE, dv)
            }

            // 设备数据，拿到后，上传
            if (deviceInfoTypesArray.contains("T2")){
                dt.fetchBattery("batterypath") { data ->
                    HttpManager_boom.getInstance().requestForDevice(Url_boom.PATH_BATTERY, data)
                }
            }

        }catch (e:Exception){
            if (Constant_boom.Debug) e.printStackTrace()
        }
    }
}